<#import "/common/page.html" as p> 
<div class="ibox">
  <div class="ibox-title">
	  <h5>明星管理</h5>
	  <div class="nowrap pull-right" style="margin-top:10px">
	    <button data-modal='star/edit' data-title="添加明星" class='layui-btn layui-btn-small'><i class='fa fa-plus'></i> 添加明星</button>
	    <button onclick="imgscan();" class='layui-btn layui-btn-small'><i class='fa fa-refresh'></i> 更新图片信息</button>
	  </div>
  </div>
<div class="ibox-content fadeInUp animated">
  
<!-- 表单搜索 开始 -->
<form class="animated form-search" action="star/index" onsubmit="return false" method="get" data-search>

    <div class="row">
        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="name" value="${search_name!''}" placeholder="明星名称"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
            	<input type='hidden' value='1' name='page'/>
                <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
            </div>
        </div>
    </div>
</form>
<!-- 表单搜索 结束 -->
              
<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <table class="table table-hover">
        <thead>
            <tr>
                <th class='text-center'>ID</th>
                <th class='text-center'>名称</th>
                <th class='text-center'>性别</th>
                <th class='text-center'>图片</th>
                <th class='text-center'>操作</th>
            </tr>
        </thead>
        <tbody>
        
        <#list page.data as model>
             <tr>
                <td class='text-center'>${model.id?c}</td>
                <td class='text-center'>${model.name}</td>
                <td class='text-center'>
                	<span>${(model.sex==1)?string("男","女")}</span>
                </td>
                <td class='text-center'>
                	<#list model.imgs as img>
                	<img data-tips-image="" style="height:auto;max-height:32px;min-width:32px" src="${img.img!''}"/>
                	<a data-load='star/delStarImg?id=${img.id?c}' data-confirm="确定要删除吗？" title="删除图片"  href="javascript:void(0)"><i class='fa fa-remove'></i></a>
                	</#list>
                </td>
                <td class='text-center nowrap'>
                    <span class="text-explode">|</span>
                    <a data-modal='star/edit?id=${model.id?c}' href="javascript:void(0)">编辑</a>
                    <span class="text-explode">|</span>
                    <a data-modal='star/addImg?id=${model.id?c}' href="javascript:void(0)">上传图片</a>
                    <span class="text-explode">|</span>
                    <a data-load='star/del?id=${model.id?c}' data-confirm="确定要删除吗？"  href="javascript:void(0)">删除</a>
               </td>
            </tr>
          </#list>      
       </tbody>
    </table>
<p>
<ul class="pagination pull-right">

<@p.page data=page url="star/index" search_param=search_param />
 
</ul>
</p>
 
</form>

</div>  
</div>
<script>
function imgscan(){
	var url='/m/star/imgscan'; 
	$.ajax({
        type: "GET", 
        url: url,
        dataType :"json", 
        data: {},  
        success: function(data){  
        	console.log(data);
        	if(data.errorCode==0){
	            layer.msg("明星图片识别完成", {
	                icon: 1,
	                shade: this.shade,
	                scrollbar: false,
	                time: 2000,
	                shadeClose: true
	            });//保存成功提示
	        }else{
	            layer.msg(data.errorMsg, {
	                icon: 2,
	                shade: this.shade,
	                scrollbar: false,
	                time: 3000,
	                shadeClose: true
	            });
	        }
        } 
    });
}
</script>